package com.example.mapp;

import com.example.entity.RescueDrill;
import com.example.ext.entity.ExtRescueDrill;
import com.example.mapp.buildSql.RescueDrillMappSql;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * Created by simon on 2017/11/20.
 */
@Mapper
public interface RescueDrillMapp {

    @SelectProvider(type = RescueDrillMappSql.class,method = "queryList")
    List<ExtRescueDrill> findByIdList(ExtRescueDrill extRescueDrill) throws Exception;

    @Insert("insert into rescue_drill " +
            "(drill_date,drill_party_id,drill_party_name,drill_record_user_id,drill_record_user_name," +
            "pic_url,maintenance_party_id,drill_content,maintenance_party_name,drill_type,drill_stdt," +
            "drill_edt,elevator_num,community,building,unit,ladder_number," +
            "h1,m1,h2,m2,h3,m3,h4,m4,h5,m5,h6,m6,h7,m7,is_phone,is_sure_person,person_num" +
            ",is_sure_sth,is_emotion,is_timely_report,is_timely_response,is_timely_react,is_cz_person,is_connect" +
            ",is_dosth,is_anfu,is_dosth_after,is_intime,is_gout,is_quan,is_right,slcd,is_paicha,summary,safe_user_sign," +
            "maint_sing1,maint_sing2) " +
            " value " +
            "(#{drillDate},#{drillPartyId},#{drillPartyName},#{drillRecordUserId},#{drillRecordUserName}," +
            "#{picUrl},#{maintenancePartyId},#{drillContent},#{maintenancePartyName},#{drillType},#{drillStdt}," +
            "#{drillEdt},#{elevatorNum},#{community},#{building}," +
            "#{unit},#{ladderNumber},#{h1},#{m1},#{h2},#{m2},#{h3},#{m3},#{h4},#{m4}," +
            "#{h5},#{m5},#{h6},#{m6},#{h7},#{m7},#{isPhone},#{isSurePerson},#{personNum},#{isSureSth},#{isEmotion}," +
            "#{isTimelyReport},#{isTimelyResponse}," +
            "#{isTimelyReact},#{isCzPerson},#{isConnect},#{isDosth},#{isAnfu},#{isDosthAfter},#{isIntime}," +
            "#{isGout},#{isQuan},#{isRight},#{slcd}," +
            "#{isPaicha},#{summary},#{safeUserSign},#{maintSing1},#{maintSing2})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    int add(RescueDrill RescueDrill) throws Exception;
}
